<template>
  <div class="mt35">
      <el-row :gutter="20">
        <el-col :span="6" :xs="24">
          <el-card style="padding-bottom: 160px" class="left-style">
            <div slot="header" class="clearfix">
              <span style="color: #FFFFFF">个人信息</span>
            </div>
            <div>
              <div class="text-center">
                <userAvatar :user="user"/>
              </div>
              <ul class="list-group list-group-striped">
                <li class="list-group-item" style="color: #FFFFFF">
                  <svg-icon icon-class="user" />
                  用户名称
                  <div class="pull-right">{{ user.userName }}</div>
                </li>
                <li class="list-group-item" style="color: #FFFFFF">
                  <svg-icon icon-class="phone"/>
                  手机号码
                  <div class="pull-right">{{ user.phonenumber }}</div>
                </li>
                <li class="list-group-item" style="color: #FFFFFF">
                  <svg-icon icon-class="email"/>
                  用户邮箱
                  <div class="pull-right">{{ user.email }}</div>
                </li>
                <li class="list-group-item" style="color: #FFFFFF">
                  <svg-icon icon-class="peoples"/>
                  所属角色
                  <div class="pull-right">{{ roleGroup }}</div>
                </li>
                <li class="list-group-item" style="color: #FFFFFF">
                  <svg-icon icon-class="date"/>
                  创建日期
                  <div class="pull-right">{{ user.createTime }}</div>
                </li>
              </ul>
            </div>
          </el-card>
        </el-col>
        <el-col :span="18" :xs="24">
          <el-card class="left-style">
            <div slot="header" class="clearfix">
              <span style="color: #FFFFFF">基本资料</span>
            </div>
            <el-tabs v-model="activeTab" >
              <el-tab-pane label="基本资料" name="userinfo" class="el-tab-text">
                <preUserInfo :user="user"/>
              </el-tab-pane>
              <el-tab-pane label="修改密码" name="resetPwd" class="el-tab-text">
                <resetPwd :user="user"/>
              </el-tab-pane>
            </el-tabs>
          </el-card>
        </el-col>
      </el-row>
  </div>
</template>

<script>
import userAvatar from "../../user/profile/userAvatar";
import preUserInfo from "./preuserInfo";
import resetPwd from "./resetPwd";
import {getUserProfile} from "@/api/system/user";

export default {
  name: "Profile",
  components: {userAvatar, preUserInfo, resetPwd},
  data() {
    return {
      user: {},
      roleGroup: {},
      postGroup: {},
      activeTab: "userinfo"
    };
  },
  created() {
    this.getUser();
  },
  methods: {
    getUser() {
      getUserProfile().then(response => {
        this.user = response.data;
        this.roleGroup = response.roleGroup;
        this.postGroup = response.postGroup;
      });
    }
  }
};
</script>
<style>
.left-style{
  padding-bottom: 100px;
  background: #1B2B5F;
  border-radius: 8px;
  opacity: 0.9;
}
.el-tabs__item.is-top{
  color:#FFFFFF !important;
}
.el-tabs__active-bar{
  background-color: #9B9B9B  !important;
}
.el-popover{
  background: #1B2B5F !important;
  border-radius: 8px;
  color: #FFFFFF;
}
</style>
